var index_divclose,
age_ARR1 = age_ARR,
age_ARR2 = age_ARR,
heigh_ARR1 = heigh_ARR,
heigh_ARR2 = heigh_ARR,
weigh_ARR1 = weigh_ARR,
weigh_ARR2 = weigh_ARR;
window.onload=function(){
	px.onclick=function(){
		if(!px.hasClass('ed')){
			sotab1.show();
			px.addClass('ed');
		}else{
			sotab1.hide();
			px.removeClass('ed');
		}
	}
	o('areaid').onclick=areaidFn
	o('area2id').onclick=area2idFn
	user_search.onclick=function(){ZeaiM.div_left({obj:user_so,w:28});}
	ZeaiM.divMod({kind:'range',clickobj:agebtn,obj:age,end:function(e,i){o('form_age').value=e;ZEAI_CN_FORM_ext.submit();}});
	ZeaiM.divMod({kind:'range',clickobj:heighbtn,obj:heigh,end:function(e,i){o('form_heigh').value=e;ZEAI_CN_FORM_ext.submit();}});
	ZeaiM.divMod({kind:'range',obj:age,end:function(e,i){o('form_age').value=e;}});
	ZeaiM.divMod({kind:'range',obj:heigh,end:function(e,i){o('form_heigh').value=e;}});
	ZeaiM.divMod({kind:'range',obj:weigh,end:function(e,i){o('form_weigh').value=e;}});
	if(!zeai.empty(o('showtype_box'))){
		var scsA = scs.split('&'),newA=[],s;
		for(var k=0;k<scsA.length;k++) {
			s=scsA[k].split('=');
			if(!zeai.empty(s[1])){
				newA.push(s[0]+'='+s[1]);
			}
		}
		zeai.listEach(zeai.tag(o('showtype_box'),'a'),function(obj,i){obj.onclick=function(){showtypeFn(newA,i);}});
	}
	processHash_index();
}
function showtypeFn(newA,i){
	var A=[];
	for(var k=0;k<newA.length;k++) {
		ss=newA[k].split('=');
		if(ss[0]=='showtype'){
			A.push(ss[0]+'='+(i+1));
		}else{
			A.push(newA[k]);
		}
	}
	var A=A.join("&");
	zeai.openurl('index'+zeai.ajxext+A);
}
function areaidFn(){
	ZeaiM.div_up({obj:areabox,h:36});
	ZEAI_area({areaid:o('form_areaid').value,areatitle:o('form_areatitle').value,ul:areabox.children[0],bx:true,str:'job',end:function(z,e){
		o('areatitle').html(e);o('areatitle').class('ed');
		o('form_areaid').value=z;
		o('form_areatitle').value=e;
	}});
}
function area2idFn(){
	ZeaiM.div_up({obj:areabox2,h:36});
	ZEAI_area({areaid:o('form_area2id').value,areatitle:o('form_area2title').value,ul:areabox2.children[0],bx:true,str:'hj',datastr:'hj',end:function(z,e){
		o('area2title').html(e);o('area2title').class('ed');
		o('form_area2id').value=z;
		o('form_area2title').value=e;
	}});
}
function gpsbtnFn(cook_longitude,cook_latitude,cook_areatitle){
	var jurl=MHOST+'/index'+zeai.ajxext+'t=gps&showtype='+showtype;
	zeai.ajax({url:MHOST+'/index'+zeai.ajxext+'submitok=ajax_gps',js:1},function(e){var rs=zeai.jsoneval(e);
		if(rs.flag==1){
			zeai.openurl(jurl);
		}else{
			if(browser=='wx'){
				wx.getLocation({
					type: 'wgs84',
					success: function (res) {
						var latitude = res.latitude,longitude= res.longitude;
						zeai.ajax({url:MHOST+'/index'+zeai.extname,js:1,data:{submitok:'ajax_gps_save',latitude:latitude,longitude:longitude}},function(e){var rs=zeai.jsoneval(e);
							if(rs.flag==1){
								zeai.openurl(jurl);	
							}else{
								//zeai.alert('您已拒绝授权定位，将无法使用附近的人');
								setmap(showtype,cook_longitude,cook_latitude,cook_areatitle);
							}
						});
					},
					cancel: function (res) {zeai.alert('您已拒绝授权定位，将无法使用附近的人');},
					fail: function (res) {
						//zeai.msg('请开启手机本身的GPS定位后并同意授权',{time:4});
						setmap(showtype,cook_longitude,cook_latitude,cook_areatitle);
					}
				});
			}else if(browser=='app'){
				plus.geolocation.getCurrentPosition(function(p){
					zeai.ajax({url:MHOST+'/index'+zeai.extname,js:1,data:{submitok:'ajax_gps_save',latitude:p.coords.latitude,longitude:p.coords.longitude}},function(e){var rs=zeai.jsoneval(e);
						if(rs.flag==1){zeai.openurl(jurl);}else{
							//zeai.msg('定位失败:' + rs.msg,{time:4});
							setmap(showtype,cook_longitude,cook_latitude,cook_areatitle);
						}
					});	
				}, function(e){
					//zeai.msg('获取定位失败:' + e.message,{time:4});
					setmap(showtype,cook_longitude,cook_latitude,cook_areatitle);
				});
			}else{
				//zeai.msg('请使用微信打开并同意获取自己的定位',{time:4});
				setmap(showtype,cook_longitude,cook_latitude,cook_areatitle);
			}
		}
	});
	function setmap(showtype,cook_longitude,cook_latitude,cook_areatitle){zeai.openurl(MHOST+'/map_set.php?kind=u&showtype='+showtype+'&longitude='+cook_longitude+'&latitude='+cook_latitude+'&areatitle='+cook_areatitle);}
}
if(pagemore){
	document.write('<input type="hidden" id="p" value="1" />');
	var loadswitch_index=true;
	window.onhashchange = processHash_index;
	document.body.onscroll = function(){
		var tt = zeai.getScrollTop(),cH= parseInt(document.documentElement.clientHeight),sH= parseInt(document.body.scrollHeight);//cH=document.documentElement.clientHeight;
		sessionStorage.tt=tt;
		if ((sH-tt-cH) <100 && loadswitch_index){
			var i = parseInt(o("p").value);
			if(i>=4 && !iflogin){
				setTimeout(function(){index_divclose=ZeaiM.div({obj:index_bounce_box,w:30,h:30});},100);
				loadswitch_index=false;	
				return false
			}
			i++;o("p").value = i;
			location.hash = "#" + i;
			if (i > ZEAI_totalP){
				location.hash = "#" + ZEAI_totalP;
				o("p").value  = ZEAI_totalP;
				return false;
			}else{
				loadswitch_index=false;
				Object.assign(zeaiOnscroll_json.data,{p:i});
				zeai.ajax(zeaiOnscroll_json,function(e){
					if (e == 'end'){
						return false;
					}else{
						ZEAI_list.append(e);
						sessionStorage.tmplist_index += e;
						loadswitch_index=true;
					}
				});
			}
		}
		backtopFn();
	}
	window.addEventListener('pageshow', function (event) {
		if(event.persisted || window.performance && window.performance.navigation.type == 2){
			o('ZEAI_list').html(sessionStorage.tmplist_index);
			zeai.setScrollTop(sessionStorage.tt);
			loadswitch_index=true;
		}
	},false);
}
function processHash_index () {
	var hashStr = location.hash.replace("#","");
	if (hashStr){
		o("p").value = hashStr;
		//o('ZEAI_list').html(sessionStorage.tmplist);
	}else{
		sessionStorage.tmplist_index= o('ZEAI_list').innerHTML;
		loadswitch_index=true;
		sessionStorage.tt=0;
	}
}

/*Marquee*/
var zeai_iMarquee = function (id, tag, heigh, speed, delay) {
	var me = this;
	me.EL = document.getElementById(id);
	me.PA = 0;
	me.TI = null;
	me.LH = heigh;
	me.SP = speed;
	me.DY = delay;
	me.exec = function () {
		if (me.PA) return;
		me.EL.scrollTop += 2;
		if (me.EL.scrollTop % me.LH <= 1) {
			clearInterval(me.TI);
			me.EL.appendChild(me.EL.getElementsByTagName(tag)[0]);
			me.EL.scrollTop = 0;
			setTimeout(me.start, me.DY * 1000);
		}
	};
	me.start = function () {if (me.EL.scrollHeight - me.EL.offsetHeight >= me.LH) me.TI = setInterval(me.exec, me.SP);};
	//me.EL.onmouseover = function () { me.PA = 1 };
	//me.EL.onmouseout = function () { me.PA = 0 };
	setTimeout(me.start, me.DY * 1000);
};
function zeai_iMarqueeFn(){
	zeai.ajax({url:MHOST+'/index'+zeai.ajxext+'submitok=ajax_iMarquee'},function(e){
		if(!zeai.empty(e)){
			iMarquee.html(e);
			setTimeout(function(){new zeai_iMarquee("iMarquee","li",30,20,1.5);},100);
		}
	});
}
function iMarqueeBox_off(that){
	var f=that.parentNode;f=f.parentNode;
	f.parentNode.removeChild(f);
}